package com.xt.base.reflection;

public final class UV {
	
	static public class Tuple<T, V> {
		final public T a;

		final public V b;

		public Tuple(T a, V b) {
			this.a = a;
			this.b = b;
		}

		public String toString() {
			return a + ":" + b;
		}
		
		public boolean equals(Object other){
			if(other == null)return false;
			if(!Tuple.class.isInstance(other))
				return false;
			Tuple o = (Tuple)other;
			return a != null && o.a != null && a.equals(o.a) &&
					b != null && o.b != null && b.equals(o.b);
		}
	}

	static public class Thple<T, V, I> extends Tuple<T, V> {
		final public I c;

		public Thple(T a, V b, I c) {
			super(a, b);
			this.c = c;
		}

		public String toString() {
			return super.toString() + ":" + c;
		}
		public boolean equals(Object other){
			if(other == null)return false;
			if(!Thple.class.isInstance(other))
				return false;
			Thple o = (Thple)other;
			return a != null && o.a != null && a.equals(o.a) &&
					b != null && o.b != null && b.equals(o.b) &&
					c != null && o.c != null && c.equals(o.c);
		}
	}

	static public class Fuple<T, V, I, L> extends Thple<T, V, I> {
		final public L d;

		public Fuple(T a, V b, I c, L d) {
			super(a, b, c);
			this.d = d;
		}

		public String toString() {
			return super.toString() + ":" + d;
		}
		public boolean equals(Object other){
			if(other == null)return false;
			if(!Fuple.class.isInstance(other))
				return false;
			Fuple o = (Fuple)other;
			return a != null && o.a != null && a.equals(o.a) &&
					b != null && o.b != null && b.equals(o.b) &&
					c != null && o.c != null && c.equals(o.c) &&
					d != null && o.d != null && d.equals(o.d);
		}
	}

	@SuppressWarnings("unchecked")
	static public <T> Tuple<T, T>[] getTuple(T[] input) {
		Tuple<T, T>[] rts = new Tuple[Math.round((input.length + 1) / 2)];
		for (int i = 0; i < input.length; i += 2) {
			rts[i / 2] = new Tuple<T, T>(input[i],
					i + 1 < input.length ? input[i + 1] : null);
		}
		return rts;
	}
}
